<?php /* Smarty version Smarty-3.1.6, created on 2018-03-12 14:15:06
         compiled from "./Tpl/Admin\Redpack\edit.html" */ ?>
<?php /*%%SmartyHeaderCode:309505aa61aea30eab4-63581579%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '708e0a6fbb39de9fb012f1ded95d1786ae87101b' => 
    array (
      0 => './Tpl/Admin\\Redpack\\edit.html',
      1 => 1518077326,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '309505aa61aea30eab4-63581579',
  'function' => 
  array (
  ),
  'variables' => 
  array (
    'obj' => 0,
    'canEdit' => 0,
    'item' => 0,
    'key' => 0,
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.6',
  'unifunc' => 'content_5aa61aea3d5e3',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_5aa61aea3d5e3')) {function content_5aa61aea3d5e3($_smarty_tpl) {?><?php if (!is_callable('smarty_modifier_date_format')) include 'E:\\findmeServer\\ThinkPHP\\Library\\Vendor\\Smarty\\plugins\\modifier.date_format.php';
?><?php echo $_smarty_tpl->getSubTemplate ("Public/top.html", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>

	</head>
	<body>
		<div id="warpper">
            <div class="content">
                <div class="location">红包活动</div>
                <?php echo $_smarty_tpl->getSubTemplate ("./nav.html", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>


                <form action="<?php echo u('update');?>
" class="ui-form" id="addManagerForm" method="post" >
                <div class="topic">红包活动 <?php if ($_smarty_tpl->tpl_vars['obj']->value['id']){?>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:red"> 当活动没有人参加过，且已下线，才可编辑 </span>
                    <?php if ($_smarty_tpl->tpl_vars['canEdit']->value){?><b>可以编辑</b><?php }else{ ?><b>不可编辑</b><?php }?>
                    <?php }?></div>
                <div class="form-box border0 border-box" id="setdiv">
                        <input type="hidden" name="id" value="<?php echo (($tmp = @$_smarty_tpl->tpl_vars['obj']->value['id'])===null||$tmp==='' ? 0 : $tmp);?>
" />
                        <div class="ui-form-item">
                            <label class="ui-label">活动名称</label>
                            <input type="text" class="ui-text"  name="title" value="<?php echo $_smarty_tpl->tpl_vars['obj']->value['title'];?>
" required/>
                        </div>

                        <div class="ui-form-item">
                            <label class="ui-label">祝福语</label>
                            <textarea  class="ui-textarea"  name="wish"  required><?php echo $_smarty_tpl->tpl_vars['obj']->value['wish'];?>
</textarea>
                            <i>换行分隔</i>
                        </div>
                    <?php  $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['item']->_loop = false;
 $_smarty_tpl->tpl_vars['key'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['obj']->value['wave']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['item']->key => $_smarty_tpl->tpl_vars['item']->value){
$_smarty_tpl->tpl_vars['item']->_loop = true;
 $_smarty_tpl->tpl_vars['key']->value = $_smarty_tpl->tpl_vars['item']->key;
?>
                        <div class="content waveset">
                            <div class="topic">波次<i class="wave">1</i> &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" onclick="removeWave(this)" class="del-button">删除</a></div>
                            <div class="form-box border0 border-box">
                            <div class="ui-form-item">
                                <label class="ui-label">金额</label>
                                <input type="phone" class="ui-text"  name="money[]" value="<?php echo $_smarty_tpl->tpl_vars['item']->value['money']/100;?>
" required/>
                            </div>
                            <div class="ui-form-item">
                                <label class="ui-label">领奖时间</label>
                                <input id="startDate<?php echo $_smarty_tpl->tpl_vars['key']->value;?>
" name="startTime[]" value="<?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['item']->value['beginTime'],'%Y-%m-%d %H:%M:%S');?>
" readonly class="date ui-select" type="text" required/>
                                至
                                <input id="endDate<?php echo $_smarty_tpl->tpl_vars['key']->value;?>
" name="endTime[]" readonly value="<?php echo smarty_modifier_date_format($_smarty_tpl->tpl_vars['item']->value['endTime'],'%Y-%m-%d %H:%M:%S');?>
" class="date ui-select" type="text" required/>
                            </div>

                            <div class="ui-form-item">
                                <label class="ui-label">奖励配置</label>
                                <textarea  class="ui-textarea"  name="set[]" placeholder="金额下限,金额上限,数量"  required><?php echo $_smarty_tpl->tpl_vars['item']->value['waveSet'];?>
</textarea>
                                <i>换行分隔;</i>
                            </div>
                                </div>
                        </div>
                    <?php } ?>
                </div>
                    <?php if ($_smarty_tpl->tpl_vars['obj']->value['id']==0){?>
                        <div class="integral_btn-group">
                            <button type="button"  class="ui-button " id="moreWave">增加波次</button>
                            <input type="submit" value="提交" class="ui-button"/>
                            <input type="reset"  value="清空" class="ui-button fade-o-butn"/>
                        </div>
                    <?php }else{ ?>
                        <?php if ($_smarty_tpl->tpl_vars['canEdit']->value){?>
                            <div class="integral_btn-group">
                                <button type="button"  class="ui-button " id="moreWave">增加波次</button>
                                <input type="submit" value="修改" class="ui-button"/>
                            </div>
                        <?php }?>
                    <?php }?>

                </form>
            </div>
		</div>

        <div class="content waveset" id="template" style="display: none">
            <div class="topic">波次<i class="wave">1</i> &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" onclick="removeWave(this)" class="del-button">删除</a></div>
            <div class="form-box border0 border-box">
                <div class="ui-form-item">
                    <label class="ui-label">金额</label>
                    <input type="phone" class="ui-text"  name="money[]" value="<?php echo $_smarty_tpl->tpl_vars['obj']->value['title'];?>
" required/>
                </div>
                <div class="ui-form-item">
                    <label class="ui-label">领奖时间</label>
                    <input  name="startTime[]" readonly value="" class="timeBegin  ui-select" type="text" required/>
                    至
                    <input  name="endTime[]" readonly value="" class="timeEnd  ui-select" type="text" required/>
                </div>

                <div class="ui-form-item">
                    <label class="ui-label">奖励配置</label>
                    <textarea  class="ui-textarea"  name="set[]" placeholder="金额下限,金额上限,数量"   required><?php echo $_smarty_tpl->tpl_vars['obj']->value['title'];?>
</textarea>
                    <i>换行分隔</i>
                </div>
            </div>
        </div>



        <?php echo $_smarty_tpl->getSubTemplate ("Public/foot.html", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>

		<script>
            var num=99;
            $(document).ready(function(){
                resetWaveNum();
                $('#moreWave').click(function(e){
                    num++;
                    var $wave=$('#template').clone().removeAttr('id').appendTo('#setdiv').show();
                    $wave.find('.timeBegin').attr('id','startDate'+num).addClass('date');
                    $wave.find('.timeEnd').attr('id','endDate'+num).addClass('date');
                    resetWaveNum();
                });

                $("form").submit(function () {
                    layer.msg("正在提交数据...",{time:999});
                    $.post("<?php echo U('update');?>
",$(this).serialize(), function(data){
                        if(data.status==0){
                             layer.msg(data.info);
                        }else{
                            layer.msg(data.info);
                            location.href="<?php echo U('setList');?>
";
                        }
                    }, 'json');
                    return false;
                });
            });


            function resetWaveNum(){
                $('.wave').each(function(i){
                    $(this).text(i+1);
                });


                var ids=new Array()

                $('.date').each(function(i){
                    ids[i]=$(this).attr('id');
                });


                var nums=ids.length;
                var next='';
                var prev='';

                for(var i=0;i<nums;i++){
                    console.log('当前：'+ids[i]);
                    if(i==0){//first
                        next=ids[i+1];
                        (function(o){
                            $("#" + ids[i]).unbind().bind('click focus',function () {
                                WdatePicker({
                                    dateFmt: 'yyyy-MM-dd HH:mm:ss',
                                    maxDate:'#F{$dp.$D(\''+o+'\')}',
                                })
                            });
                         })(next);
                    }else if(i==nums-1){//last
                        prev=ids[i-1];
                        (function(o) {
                            $("#" + ids[i]).unbind().bind('click focus', function () {
                                WdatePicker({
                                    dateFmt: 'yyyy-MM-dd HH:mm:ss',
                                    minDate: '#F{$dp.$D(\'' + o + '\')}'
                                })
                            });
                        })(prev);
                    }else{//middle
                        prev=ids[i-1];
                        next=ids[i+1];
                        (function(o1,o2){
                            $("#" + ids[i]).unbind().bind('click focus',function () {
                                    WdatePicker({
                                        dateFmt: 'yyyy-MM-dd HH:mm:ss',
                                        minDate:'#F{$dp.$D(\'' + o1 + '\')}',
                                        maxDate:'#F{$dp.$D(\'' + o2 + '\')}'
                                    })
                            });
                        })(prev,next);
                    }
                }


            }

            function removeWave(obj){
                $(obj).closest(".waveset").remove();
                resetWaveNum();
            }



        </script>
	</body>
</html>
<?php }} ?>